using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Deck : MonoBehaviour {
	
	// Properties
	//
	
	public Player Owner;
	
	public List<Card> Cards;
	
	// Methods
	//
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	// Put a card from the deck to an hand
	public Card DrawCard(Hand Hand){
		
		// If there is still cards in the desk
		if(this.Cards.Count > 0){
		
			// Randomly draw a card of the deck
			System.Random rand = new System.Random();
			// We use C# random, Unity's one is not really good
			int idCardDrawn = rand.Next(0, this.Cards.Count);
			
			Card cardDrawn = this.Cards[idCardDrawn];
			
			this.Cards.RemoveAt(idCardDrawn);
			
			cardDrawn.inDeck = null;
			cardDrawn.inHand = Hand;
			
			return cardDrawn;
			
		
		} else {
			
			// There is no more cards in the deck
			return null;
			
		}
		
	}
	
}
